Efficient memory architecture for image processing