imgutils: create misc functions for dealing with buffers