adjust mktemp usage so that it works on mac too
merged