fix for jpeg encoding