Python 3 support

I've added Python 3 support with Python 2.7 compatibility. It could probably use a little more testing, but it has worked fine for me on both 2.7 and 3.