Converting image format if necessary.