fwrite -> write; JPEG timing improvements