Fix mkstemp open flags.

@carlosmn: make sure that the temporary file is truncated.