implemented feedback given by Taar at http://www.reddit.com/r/learnpython/comments/2m2tjj/codereview_jpglitch_a_jpeg_glitching_script/