Bah! Screw Tali! An insignificant annoyance, like the rest of her inferior race that got their asses handed to them by their own creations.
But in all seriousness, usually if a squadmate ends up not loyal to the cause, they end up dead. Not sure if there really is a way to outweigh that depending on the squadmates you leave them with when holding the line. What concerns me is why you don't have full paragon or renegade? That's basically your pass through all of the consequences in the game. You should really work on that.
But concerning how it ends up in Mass Effect 3 and if you can't keep them both alive, I would have kept Legion alive if I were you. Not because I am a Geth enthusiast by any means (if the username isn't a hint enough), but I find that the situation that ends up going on in Mass Effect 3 with Legion and Tali is much better with Legion being alive, because what you get if he dies in ME2 is pretty lame, unlike Tali, in which the character that takes her place in the story is still a good one. The only con being, Tali is a squadmate in ME3, and you'll be a squadmate short. Not that she is all that useful anyway. I found her useless in ME2 and in ME3 against anything that isn't synthetic. And you're not fighting many synthetics in ME2 or ME3 as you are in ME1. Although her major role in ME3 does involve fighting the Geth. Either way, so long as you at least have Garrus, you're in good hands.
But overall, it IS best to just have both of them on your side and to keep everyone alive.
I would have much rather left her face a mystery for the player to imagine on their own, rather than that crap Bioware pulled off. So lame.