Fix binary file output in Python 3.
In Python 3, support both binary and Unicode output.
Test Python 3 bytes/Unicode output; use raw bytes in Python 2.
Make sure we clear the error indicator.
Use bytes not Unicode strings.
Python 3 does not use __cmp__ - define __eq__ too.
Use io type compatible with print().
Fixes to work with Python 3.
Python 3 fixes.
Python 3 fixes.
Python 3 fixes.
Python 3 fixes.