[python] How to duplicate sys.stdout to a log file?