added PIL import with try, except statements