Py3k compatibility

This also updates the Flask-SQLAlchemy to a recent, py3k-compatible version.

All tests are green (tested on 2.7 and 3.4).