added support for python 3

I have tested this. It seems to be working fine.