Added C code + cython wrapper for TWM

Since TWM was quite slow we added c code for twm and a cython wrapper to access it in python, in the same way as the python module.