What do you say when a girl says she is ugly but she isn't but I don't want to say it in a way where it sounds like I'm flirting but still want to make her feel better?

I'd say just be easygoing about it. But don't worry about it because if you seem nervous, it will seem as if you are flirting. Honestly, it depends on how well you know it. If you know her very well and she knows you wouldn't like like her, then just say it like if she says that say, "Oh, come on." or maybe you know someone who likes her then you can go with the "I bet I know someone who doesn't think that ;)" or the like.

Chances are she's just feeling down about it and just wants someone to say something like that back. I bet you'll make her day :)