In every case of felony, when the accused is in custody, or as soon as he may be arrested, the clerk of the court where an indictment has been presented shall immediately make a certified copy of the same, and deliver such copy to the sheriff, together with a writ directed to such sheriff, commanding him forthwith to deliver such certified copy to the accused.