allow to be used with python2.7

These few changes would allow the code to be used with python 2.7.