Add Python 3 support without droping Python 2 support

Hi,
These changes make the library running with Python 2 and 3. I think the commit messages are self-explanatory. So please test it and consider to merge it.