1. extract config to config.py
2. change syntax to python 2.7+ and fix encoding