catch exceptions, deallocate, release GIL in write_entries()

Note: when writing a single entry with write(), the GIL is not released
because:

- releasing the GIL has overhead
- entries typically need to be written in a specific order so
  single-threaded use makes sense for write().