Python 3 support

This fixes python 3 compat in a doctest and silences an unclosed file warning.

For me, this is working fine in python3.3 and python3.4, and tox doesn't complain anymore (see #3), so I suggest to mark the package as "python 3 supported".