fix _tmpfile to allocate mode argument correctly

Same as #2828 but pointing to incoming. Small bug.