Python 3 Compatibility

This includes a few minor changes to get things working with Python 3.  Tests pass with 3.4.1.