do the splitting in write()

Signed-off-by: Stephen Gran <stephen.gran@piksel.com>