Update for Modern OS X'es that don't use /tmp

Dynamically choose temporary directory on OS X, such that this works on recent OS X'es.