fix auto-detect on MacOSX
fix Python 3 compatibility