The magistrate is required to reduce the examination of the accused to writing, if the accused submits to an examination, and also all the evidence adduced on both sides, and is authorized to discharge, bail, or commit the accused and to take all necessary recognizances to enforce the appearance of the defendant, the prosecutor or witnesses at the proper court.