python log stdout and stderr to file