Index: trunk/pswarp/src/pswarpTransformReadout_Opt.c
===================================================================
--- trunk/pswarp/src/pswarpTransformReadout_Opt.c	(revision 15334)
+++ trunk/pswarp/src/pswarpTransformReadout_Opt.c	(revision 17780)
@@ -97,4 +97,5 @@
         nextGridX = nextGridXo;
         map = grid->maps[gridX][gridY];
+        int yOut = y - outRow0;         // Position on image
         for (int x = minX; x < maxX; x++) {
             if (x >= nextGridX) {
@@ -127,21 +128,21 @@
                 psError(PS_ERR_UNKNOWN, false, "Unable to interpolate image.");
                 psFree(interp);
-                psFree (inPix);
-                psFree (grid);
+                psFree(inPix);
+                psFree(grid);
                 return false;
             }
-            outImageData[y-outRow0][x-outCol0] = imageValue;
+            int xOut = x - outCol0;     // Position on image
+            outImageData[yOut][xOut] = imageValue;
             if (inVar) {
-                outVarData[y-outRow0][x-outCol0] = varValue;
+                outVarData[yOut][xOut] = varValue;
             }
             if (outMaskData) {
-                outMaskData[y-outRow0][x-outCol0] = maskValue;
-            }
-        }
-    }
-
+                outMaskData[yOut][xOut] = maskValue;
+            }
+        }
+    }
     psFree(interp);
-    psFree (inPix);
-    psFree (grid);
+    psFree(inPix);
+    psFree(grid);
 
     // Transform sources
