Fix Thread patch for Py3
Changes for Py3 compatibility