Fix compatibility with older version of PIL