Make code compatible with Python 3

The test suite succeeds when run under Python 3.4.0. Absolutely no attempt has
been made to make the codebase backwards-compatible with Python 2. Adding a
variety of `from __future__ import X` statements should fix this.