All sums earned by any prisoner may be retained until he has completed his sentence, or until he is released or discharged, and shall thereupon be paid to him. If any prisoner has dependents, his compensation shall be paid to such dependents monthly as earned.