Use Dir.tmpdir instead of ./tmp/test

./tmp/test may not exist and may not be writable.  Using the temporary
directory should always be safe.

Fixes ruby bug #7717