Towards Python 2/3 compatibility (take 2)

Here is an initial set of patches for a Py2/3 compatible codebase. Python 3 is not yet supported, but these initial patches should be easy to review and take us in the right direction. With any luck, the tests should be passing this time ...