Section 79. A person held in custody or committed upon a criminal charge, if entitled to be released on bail, or a person held in custody or committed as a witness to a crime, may, instead of giving surety or sureties, at any time give his personal recognizance to appear before the court and deposit the amount of the bail which he is ordered to furnish, or bonds or a properly assigned bank book, of the kind and in the amount and under the conditions set forth in section fifty-seven for making deposit of like nature, with the court, clerk of the court or magistrate authorized to take such recognizance, who shall give him a certificate thereof, and upon delivering said certificate to the officer in whose custody he is, shall be released. The court or magistrate shall forthwith, upon receipt of such amount, deposit it with the clerk of the court.