Adds tox and Python 3 compatiblity

I've hit a few Python 3 incompatibilities which I've fixed. I've also added a `tox.ini`, to run the tests more easily (using just `$ tox`).