use new ImageData class and simplify a lot