added support for installing as python library

I added a setup.py script and made a few changes. Now it can be installed as a python library with "python setup.py install".