swig-python: add support for python 2.7/legacy

In principle this is a big hack as it modifies the python class at
runtime. Since it's python legacy I hope it won't stay that long.

Note: Python 2 has no binary datatype so the API has changed a bit