Override stdout differently on Python 2 and 3
Merge pull request #2283 from mdboom/stdout_override

Incorrect overriding of sys.stdout