Fix indexing bug in freeimage plugin