huge changes, added a cast function, moved a lot of functions to
mrimage_utils, such as reading and writing.