Fixed issue where the encoding was not correct when the contents of the ...

...file were passed directly as a stream (and PYTHONIOENCODING was properly set).

This issue was found in the autopep8.py integration into PyDev (https://sw-brainwy.rhcloud.com/tracker/PyDev/402) -- PyDev wasn't passing the PYTHONIOENCODING encoding to match the file, but even after passing it autopep8.py still gave garbled results back because it always used the locale encoding and not the one to match the file (with this patch, integrators must make sure that PYTHONIOENCODING is properly set so that stdin/stdout have the proper encoding set).