The boards of supervisors may provide for the working of public roads with the convicts sentenced to the county jails, or committed for failure to pay the fine and costs imposed upon them; and if they do so, they may make the necessary contracts for that purpose, or employ suitable persons to have charge of and superintend the labor of the convicts. The board of supervisors may require the contractor of any road to take and work the convicts sentenced to the county jail, or committed to same to pay fine and cost imposed upon them, upon such terms and conditions as the said board and contractor may agree upon.