Ported library to work with Python 3

I've tested this with Python 2.7 and Python 3.3, everything seems to work for me.