People with sexual proclivities towards children should be neutered. Taxpayers wouldn't have to foot the bill for their existence in prison, and society would leave nothing to chance in terms of the potential danger posed to children by that person living amongst the rest of society.
The exception would be instances of statutory rape in which the victim is within a year or two of the age of consent and the accused is within the same general age bracket as the victim. The reason I would exempt these cases is that the perpetrators in cases such as these may not necessarily be engaging in "predatory" sexual behavior despite being in violation of the law.
If an 18 year old boy has sex with a 16 girl, it's a whole helluva lot different than a 38 year old man fornicating with the same girl. In one case, a teenage boy is trying to get laid by a girl he could legitimately date based on their respective ages. In the other case, a sexual predator is robbing a child of her innocence in a disgusting act of pedophilia.
In my opinion, the latter of these instances is a serious crime. The former is a minor offense at the absolute worst.
Under the system I (and others) have proposed, the 38 year old would be eligible for immediate release from prison in he agrees to be castrated, either by way of chemical castration or the traditional manner, whichever the soon-to-be eunuch prefers.
For what it's worth, the state of Louisiana currently has a similar law in place that enables the state to castrate pedophiles if the offender agree.