You need to see a lawyer, immediately. This is over and you would be wise to start making plans to formalize custody and visitation, child support and so on.
He is playing you and her for fools, and manipulating the both of you. There is no future here for you, OP. It's way too damaged and he has no respect for you.
If this comes out, well, take your lumps. You were interacting inappropriately with him while you knew he was in a relationship, so there is not much more you can do but admit your own role and let the chips fall where they may. He is a total tool, yes, but you knew better than to send sexy pictures to him. There is no way to spin that which makes you look innocent, because you weren't.
It's time to chart a new path for yourself. This is a total mess now but you can have a happier future without him as anything but a co-parent to your children.