python redirect sys.stdout to file