Add Python3 compatibility

Here is a small patch to allow this to work on Python3 as well.
Cheers,
C.