2to3 fixes and refactoring

General Python 3 fixes to `qds-sdk-py` including manual edits and automatic fixes from `2to3`.  Tested it with a few queries and it seems to work fine.