Ensure java.io.tmpdir is available before using it

Some environments do not have a tmpdir so it can be null.