Use mmap to write indexer packfile

As discussed in #2338, fix the problem by using mmap for writing as well.