Minimize the chance of a library corruption

- [x] Handle writing errors
- [x] Handle reading errors

This PR also renames `LibraryReader` to `LibraryDeserializer` and `LibraryWriter` to `LibrarySerializer`