fix PIL image extension format checking