Fix writertype argument, return values, docstrings

- fix handling of writertype argument
- write() and write_entries() return number of entries written
- add docstrings