writing images index to file