fixed spool_mktemp()

Fixed uninitialized variable `fd'. 
Fixed temp file creation retry logic.