Python 2.7 support

Not ready to merge yet, as this branch is not compatible with Python 3.

All tests and doctests now pass under Python 2.7.8. My intention is to fix this up so that it works under either Python 2 or 3, but I wanted to put this here to get your feedback in the meantime.

Sorry for all the whitespace changes (automatic, courtesy of Atom); somehow I thought Github could hide them when reviewing a pull request.