ENH: add temporary directory context managers

Context managers for working in temporary directories.
BUG: do not write temporary files into source tree

Avoid writing temporary files into the scipy data directory; use a
temporary directory instead.
Merge pull request #4198 from matthew-brett/tmp-file-writing

BUG: io: fix permissions errors in netcdf tests

Netcdf tests failing when installed into system directories because the
tests are writing to the scipy/io/tests/data directory.

Add temporary directory context manager (from nibabel) and use it for
writing the test files.