Added Python3 support. Now Python 2 or 3 can be used with the same code

The code is runnable with Python3 and Python2 now. Tested with Python 2.7 and Python 3.3.
Please write code in the future for Python 2 and 3, so both are supported
don't use try/except for such stuff.

have a _compat.py module (see pocoo projects, like werkzeug, flask, jinja2, ...) and check the PY2 flag from there. something like:
mode = 'w+bx' if PY2 else 'w+b'