Check if mktemp is available before using it.

Fixes #1514.