WIP: Py3 compat

Python 3 compatibility changes.

The tests and doctests run and pass with Python 3.3

There was one test failure I didn't understand with Python 2.7 - I am looking at it now.

Please do review these changes though.  It would be good to get some comments.