added buffered write support