--- a/AutoPano.c
+++ b/AutoPano.c
@@ -378,13 +378,13 @@
 	fprintf(pto, "p f2 w3000 h1500 v360  n\"JPEG q90\"\n");
 	fprintf(pto, "m g1 i0\n\n");
 	
-	int imageIndex = 0;
+       void *imageIndex = NULL;
 	HashTable* imageNameTab = HashTable_new0 (NULL, NULL);
 	ArrayList* resolutions = ArrayList_new0 (Resolution_delete);
 	int i;
 	for(i=0; i<ArrayList_Count(mm->keySets); i++) {
 		KeypointXMLList* kx = (KeypointXMLList*) ArrayList_GetItem(mm->keySets, i);
-		HashTable_AddItem(imageNameTab, kx->imageFile, (void*)imageIndex);
+               HashTable_AddItem(imageNameTab, kx->imageFile, imageIndex);
 		ArrayList_AddItem(resolutions, Resolution_new (kx->xDim, kx->yDim));
 		
 		char*  imageFile = kx->imageFile;
@@ -416,14 +416,14 @@
 			rotation = pos->rotation;
 		}
 		
-		if (imageIndex == 0 || refIdx == -1) {
+               if (imageIndex == NULL || refIdx == -1) {
 			fprintf(pto, "i w%d h%d f0 a0 b-0.01 c0 d0 e0 p%g r%g v180 y%g  u10 n\"%s\"\n",
 				kx->xDim, kx->yDim, pitch, rotation, yaw, imageFile);
 		} else {
 			fprintf(pto, "i w%d h%d f0 a=%d b=%d c=%d d0 e0 p%g r%g v=%d y%g  u10 n\"%s\"\n",
 				kx->xDim, kx->yDim, refIdx, refIdx, refIdx, pitch, rotation, refIdx, yaw, imageFile);
 		}
-		imageIndex += 1;
+               imageIndex = (void *)(((char *)imageIndex) + 1);
 	}
 	
 	fprintf(pto, "\nv p1 r1 y1\n\n");
@@ -437,11 +437,11 @@
 			Match* m = (Match*) ArrayList_GetItem(ms->matches, k);
 			if (integerCoordinates == false) {
 				fprintf(pto, "c n%d N%d x%.6f y%.6f X%.6f Y%.6f t0\n",
-					(int)HashTable_GetItem(imageNameTab, ms->file1), (int)HashTable_GetItem(imageNameTab, ms->file2),
+                        (int)(size_t)HashTable_GetItem(imageNameTab, ms->file1), (int)(size_t)HashTable_GetItem(imageNameTab, ms->file2),
 					m->kp1->x, m->kp1->y, m->kp2->x, m->kp2->y);
 			} else {
 				fprintf(pto, "c n%d N%d x%d y%d X%d Y%d t0\n",
-					(int)HashTable_GetItem(imageNameTab, ms->file1), (int)HashTable_GetItem(imageNameTab, ms->file2),
+                                       (int)(size_t)HashTable_GetItem(imageNameTab, ms->file1), (int)(size_t)HashTable_GetItem(imageNameTab, ms->file2),
 					(int) (m->kp1->x + 0.5), (int) (m->kp1->y + 0.5),
 					(int) (m->kp2->x + 0.5), (int) (m->kp2->y + 0.5));
 			}