Change how to handle tempfile

Tempfile is removed when exiting the block. So occasionally tempfile is removed before send_file method.

So quit to use the block with tempfile and unlink file inside ensure block.