Please check 24862, which includes a patch:
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=24862
The issue is that (at least on Mac OS 10.12) mkstemp will only accept specific flags.