Imprisonment is not prescribed as a punishment in Kautilya's "Arthashastra." People were locked up because they were under investigation for a serious offence or unable to pay a fine imposed on them.
Apart from Judges, high officials also could imprison people for non-payment of fines. The usual modes of punishment were fines & also mutilation (much before the advent of Islam!) which could be avoided by a heavy fine. Of course, capital punishment could be awarded for a variety of offences, not necessarily "in the rarest of rare cases."
So in the Kautilyan State, probably the most corrupt of the present day state organs, namely the Department of Prisons, was entirely absent. Also there is a conundrum here. Offenders against society, especially murderers, are now being housed, fed & given medical support by the tax-payers money belonging to the society, which they have harmed & during imprisonment do not economically contribute to. Is this not unfair? Unfortunately, this has become a global norm due to a misguided concept of humanity.
As a senior official remarked recently, the jail inmates are provided access to dish TV & watch current films (dealing mostly with crime) & come out street-smart & hardened to take advantage of every loophole of the law with the help of unscrupulous lawyers. Also it passes understanding as to how the accused in serious crimes, ostensibly many belonging to the poorer classes can afford to go on appealing right up to the Supreme Court & even file appeals beyond that also.
As a footnote on a related subject, even the women were safer during the Regency period in U.K. as evinced by Jane Austen's heroines walking fearlessly alone in English countryside, whereas a single woman was abducted, assaulted & killed by a Police Officer, no less, in busy crowded London & the accused will spend 20 years supported by tax-payers' money!