fixed incompatibilities with python 3 (not tested)