If the judgment is for imprisonment, the defendant must forthwith be committed to the custody of the proper officer, and by him detained until the judgment is complied with. The same procedure is to be followed when the judgment is for a fine and alternative imprisonment if the fine is not paid. If after he has started to serve the alternative imprisonment for failure to pay the fine, the prisoner wants to pay it, he shall be credited a dollar for each day of imprisonment which he may have served for such failure to pay.