Fixed index calculation

Changed the index calculation so that every element of the 'rnd' array is accessed exactly once. Moved variable declarations closer to first assignment (narrowing scope). Introduced 'width' so as to make it obvious that this value returned from 'PixelGetNextIteratorRow' is not used in any calculation (or anywhere).