Make sensible temporary filenames and avoid leaking them

Signed-off-by: David Scott <dave.scott@eu.citrix.com>