If any person, party or witness disobeys an order of the judge or master, duly served, such person, party or witness may be punished by the judge or master as for a contempt. In all cases of commitment under this chapter the person committed may, in case of inability to perform the act required or to endure the imprisonment, be discharged from imprisonment by the court or judge committing him or the court in which the judgment was rendered, on such terms as may be just.