log to stderr and work around a python regression

http://bugs.python.org/issue13601
change directory to sys.path[0]