bug fixes, added chunk processing to buffer

Added chunk processor for writing to a buffer. Fixed chunk length processing.
Added blank I/O close function.