clean up tmp files in REST

the reason that we unlink those files quite late is the MIME::Entity
object($ent) still makes use of them.
Merge branch '4.0/clean-rest-tmp-files' into 4.0-trunk