Python Threshold Image Generator