Adds 'image first' and 'image nth' commands, generalizes random_image a little bit