(3)Notwithstanding anything contained in this section, where a person is found guilty of a civil contempt, the court, if it considers that a fine will not meet the ends of justice and that a sentence of imprisonment is necessary shall, instead of sentencing him to simple imprisonment, direct that he be detained in a civil prison for such period not exceeding six months as it may think fit.