Update to support Python 3

I've run the tests on Python 2.7 and Python 3.3 and they all pass, so I think this should be OK to merge into master. I bumped the version to 0.4.0.0, but I don't know if that's the right number.