Revise write and remove write_chunk in C extension

This commit unifies the implementation of `write` and `write_chunk`
while maintaining the same functionality and interface at the Python
layer.
Handle errors in hdfs flush()