refactoring some code to generic imageio project