added implementation for reading image