Remember the seven P's and you should not find yourself in that situation often enough that you should need to worry.
Having said that, I tend to carry some Imodium with me during longish trips[*] and a regular plastic bag should take care of any unmitigable Type-B urges if a diversion is not feasible. Will take a bit of manouevering in a small cockpit, and you will need to live with the smell until you can dispose of it properly (tossing it out of the window does not qualify as proper disposal) but I don't see why it can't be done.
So there you go. Happy flights.
[*] In principle only to prevent reocurrence, but it can be used preemptively as well, four tables before you go and you won't have to worry for a good 24hrs. Not recommended though.