python flush stdout and stderr