print statement substituted with sys.stderr.write for compatibility with python 3