Py3k compatability changes

~~All tests currently pass on my computer, but it's failing on Travis due to some problem with `pillow` I have not been able to understand.~~

Now passing on Travis as well. I had to `pip install pillow` instead of using conda, which unfortunately makes the build take a while. But it should be good to go for now.