fix for python2.6

Not too happy with this solution, but could not find any information about this issue online. This has been tested with Python2.6 and Python2.7 on Linux.