Move image reading/writing into separate class