def tempPath: String = {
val path = "/tmp/" + UUID.randomUUID
(new File(path)).deleteOnExit
path
}

And then we can skip all the cleanup code?