Fix for BSD mktemp

`template` must be provided when using BSD mktemp.  This fix works on both GNU and BSD versions.