Use mktemp to create temporary directory

mktemp creates a temporary directory under /tmp by default. This reduces the
chance for collisions with other scripts using the same directory.