Python 3 support

Adds Python 3 support to the module. Also fixes some deprecation warnings, and makes tests easier to run.

All tests pass successfully.