Python3 support

Note that this is a hybrid 2/3 version; the unit tests pass under both
Python2 and Python3