add util function to cut array by boundary values
util.cutarray now returns indices
arf_writer._write_events uses iterative algorithm. Fixes #1