Don't segfault when tmpfile() fails.

Fixes bug-143 http://cbugg.hq.couchbase.com/bug/bug-143

If tmpfile() returns NULL, return COUCHSTORE_ERROR_OPEN_FILE. This can
happen if /tmp is not writable by Couchbase, as seen in JIRA MB-7587.

Change-Id: Ie67c342f3b56aa890e025b4eb747dcec385d80c6
Reviewed-on: http://review.couchbase.org/24169
Reviewed-by: Filipe David Borba Manana <fdmanana@gmail.com>
Reviewed-by: Fulu Li <fulu@couchbase.com>
Tested-by: Aaron Miller <apage43@ninjawhale.com>