added code to detect py3 and close #3. thanks @grapherd