fixing Python 3 compatibilitiy and PEP8-ing ptsampler.py