adapt mobile.py for both python 2 and python 3