Fix thread imports for Python 3