Use mkstemp() instead of tmpnam().

Fixes #1072.

Before, the following warning was generated:
warning: 'tmpnam' is deprecated: This function is provided for compatibility reasons only. Due to security concerns inherent in the design of tmpnam(3), it is highly recommended that you use mkstemp(3) instead.