Ok, I think I can live with having the PIL import inside this function. Will do!