I can answer from the point of view of Vajrayana which I practice.
If you have followed proper procedure, observed your teacher for about 12 years before deciding he/she is learned in the dharma, has realisation and follows proper ethical conduct ... and then with growing confidence have received empowerments from them which include samaya vows, have practiced guru-yoga in which one views the teacher as a perfect Buddha and so on. You are effectively bound by the vows you have taken. This is a serious matter and goes well beyond any normal human to human interaction.
Then, unfortunately for you, your teacher is found to have committed sexual misconduct etc. then you are within the framework of guru-yoga required (since you have samaya vows) to regard his/her behaviour as a kind of test ... that the perfect Buddha is teaching you something profound. This does not mean though that if asked by them, you have to engage in such acts, since the dharma teachings on this point say you should refuse to do so saying such things are undharmic. It does not mean you should brush said behaviours under the carpet, you should if appropriate report such things to the police for instance (with the awareness that this too is part of the teaching and while holding on to the bond with your teacher). They remain as far as you are concerned a spiritual master.
I know this is hard to understand but it illustrates that the vajrayana is a difficult path and that you should stick to the other yanas if you think this would be too difficult to stomach.
Do their behaviours demonstrate spiritual mastery? No but yes but maybe. On the one hand they are unacceptable and should be addressed as I said above. But if you read the lives of the mahasiddhas you will find that did all kinds of things which would make you gasp. What Tilopa did to Naropa for instance. Now ok these were already very advanced practitioners but again if they did it today they would certainly be in prison (not that they would give a damn about that) - and justly so. Having said this, we don't live in the extraordinary times of great yogis - so generally you can be sure that the acts you hear about or observe are not spiritual mastery.
How does it colour our view of their teachings? It gives us a big, big problem which is a teaching in itself. In one sense these things are clearly undharmic. We can say to ourselves clearly why that might be. Not just shock horror at the thought of it - but clearly and rationally what is it that breaks the vows and so on. From this we can learn a lot. But on another level the shock to ourselves might be the teaching. It could be quite ego smashing to go through this kind of thing - if you yourself are committed practitioner. As it says in Lo Jong 'turn everything on to the path'. When you sign up to the bodhisattva way it is not for a safe and gentle ride. It might be a series of shocks. From the other point of view it is quite possible for someone who is quite off the path to deliver a talk which perfectly follows the dharma. If so would you throw those teaching away if you found he was sleeping with his students?
The last point to make - which may sound a little trite but is necessarily true - is that the teacher, the lama or guru is simply an external focal point for you to get to know your own buddha-nature. It is this that you are relating to fundamentally. Provided this is what you are doing the rest doesn't matter.