[enh] adding support for Python 3

Quick patch for making examples work with Python 3, there might be issues since I didn't read the code carefully.