removed PIL dependency and some cleanup