python redirect stdout and stderr to file