Add Python 3 support. Passes the tests in Pythons 2.7 and 3.4.