ENH: add temporary directory context managers

Context managers for working in temporary directories.

(cherry picked from commit 6acc34aa245a19270bf192c8ab0cd9273c315e7a)
BUG: do not write temporary files into source tree

Avoid writing temporary files into the scipy data directory; use a
temporary directory instead.

(cherry picked from commit adc1a4f05a2f6471da72adb54d691336feb41ed2)