Replace imgbuf with ImageBuffer

Since this pull request will probably brake some stuff It would be nice if somebody could have a second look.
`map` usually returns a new value. Should this be `map_mut`?