Fix SSL socket wrapping and Python 2.7.9 compatibility

This is connected to GH #135 and BitBucket #165