A judge in Iran has started sentencing criminals to buy and read books instead of handing down prison terms.