Added Python 3 compatibility.

Issue #22 inspired me to quickly try this to make things work in Python 2.7 as well as Python 3. Seems to work fine.