Python3 port

This is a port to 3.x. It passes all tests but apart from that I did not perform any other checks to ensure correctness. Drops 2.5 support.