Python 3 support

Following discussion on PR #32, this adds Python 3 support without any external dependencies. Python 2.6 and above and Python 3.3 and above should work; older versions will not.

The tests are passing on Python 2 and 3; I haven't tried the examples.
There are two occurrences where this method or a descendant is called with a second argument, on lines 2650 and 2657 in my branch. It's not clear that either of them wind up calling this implementation, but I wasn't completely sure of that, so I left the extra parameter in.