Python 3 support

Todo:

- Remove memory leak in unicode to C string conversion code
- Refactor setopt to not build python parameter tuple