My understanding of the error is that res is the list of shortest path points. res[[2]] should access points from the list, as this is the same as the Part command, perhaps res is going out of scope when it shouldnt. Why this happens to me, and not to others I have no idea.
I am using Linux Ubuntu 14.04. I'll try the Wolfram Programming Cloud.
I tried again with a different image (I used Jorge Luis Borges image), in Mathematica it failed again at the last command, res[[2]] error again.
This time it didnt work in CDF Player either, same res[[2]] error