Fixes due to python3 compability

There are some fixes, to add some more compability with python 3:

- use MySQL-python only in python2.x environment (we should use pymysql in case of python3)
- use six.reraise() in case of raise(*sys.exc_info())
- fix imports from Queue (use six.moves.queue)
- use _thread instead of thread in python 3
- use six.iteritems() instead of dict.iteritems()