Implement image reader and refactorings