Additional refactoring for Python 3 support. Now down to 4 errors.

Two are 'TypeError: unorderable types: NoneType() > int()'
One is 'AttributeError: 'Resource' object has no attribute 'print_''
and the last is 'TypeError: the JSON object must be str, not 'bytes''