Remove dependency on imagemagick and work on windows