Python 3

Having run 2to3 and cleaned up a bit, the tests now all pass with `python3` in this branch. Note that this *will* break compatibility with python 2.x, so it shouldn't be merged into `master`, but there doesn't appear to be a way to make a pull-request into a new upstream branch.

I'm not sure what the best way to organise this would be - having a `python3` branch probably seems like the best idea - but I'll leave you to decide what to do about that.

This also includes the commits from my other pull-request for the master (python 2.x) version.