The best way to save yourself from their illegal confinement would be to make a bargain with them in terms of money which you are going to shell out in such a situation. May be it would prove an unnecessary tax for you, but there is no way out for you.
No life without Sun
We hear in some cases the courts warning the police for their misconduct and in some cases, punishment like suspension or demotion is also awarded by the courts to the erring officials. But it is very rare. Anyhow what we see in the TV serials will be an exaggerated version of normal happenings. So we need not compare those incidents with what is really happening on the ground.
Definitely, police will have an upper hand in our society and we should respect them and see that they will discharge their duties properly. Like all other government departments, there is corruption in police department also.
If the matter is not politically motivated /indicated then the victim or his family may meet senior officers for justice.