Added support for Python 3

I've made some minor changes to support Python 3. All tests are passing with Python 2.7 and Python 3.3.