Use "original" sys.stdout.

Fix test: 
something could have replaced sys.stdout. 
So just make sure to use the original one by simply importing it early into the module and using it directly (without accessing it by/throuh 'sys').
Also check that encoding is set and default to ascii if not.