make use of mkstemp instead of mktemp