DRY up RandomAccessConverter#getPosition

Rather than asking for the ImageMetadata twice, let's just store the
reference in a local variable.

This could avoid a potential race where another thread modifies
the ImageMetadata returned by m.get(imageIndex) while the offset is
calculated, but that's rather unlikely.

The real reason for this change is that this developer finds it
slightly more readable now.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Fix out-of-bounds in RandomAccessConverter#getPosition

Let's iterate over the correct array...

This lead to an ArrayIndexOutOfBoundsException when reading a simple
two-dimensional, 8-bit .png using a custom ImgFactory.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Merge branch 'getposition-bug-fix'

This fixes an ArrayIndexOutOfBoundsException when opening Imgs with a
custom ImgFactory.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>