Move most Python 2/3 compatibility logic into new compat.py
Fix SSL verify_mode monkey-patching on Python 2.7