Refactoring: getting a 3D array from an Image.