Python 3 support

This PR adds Python 3 support alongside Python 2 support, in a single codebase.  Python 2.6, 2.7 and 3.2 and later are supported.  Python 2.5 and earlier are no longer supported.