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).