Add range limit to n to handle less than 0 and greater than numFrames

Add check for n being less than 0 or greater than numFrames.  Came out of an issue discussed here: http://forum.doom9.org/showthread.php?p=1653750#post1653750