Add python3 support

Lots of changes.

The most controversial is probably `compat_repr`. Basically, we use it in all tests that are asserting results that have reprs of strings. In py2, unicode strings will display as `u'foo'` while in py3 they will display as `'foo'`. For this reason we put compat_repr around all of the results so that it can change what we expect depending on the python version.

Happy to talk through any of the rest of this too. I tried to keep the `if PY3` stuff to a minimum, but a few snuck in.