Python 3 support

PR not ready for merge, just adding it here so others can look at it. Currently all tests are passing in python 3, but no tests pass in python 2.6, 2.7, or pypy.