§ 771. Punishment upon return of habeas corpus. Where the accused is brought up by virtue of a writ of habeas corpus, he must, after the final order is made, be remanded to the custody of the sheriff, or other officer, to whom the writ was directed. If the final order directs that he be punished by imprisonment, or committed until the payment of a sum of money, he must be so imprisoned or committed, upon his discharge from custody under the mandate, by virtue of which he is held by the sheriff, or other officer.