The shares of stock of banks shall be deemed personal property, and shall be transferred on the books of the bank in such manner as the by-laws thereof shall direct, and as required by law. But no bank shall accept as collateral, or be the purchaser of, its own stock, except in cases where the taking of such collateral, or such purchase, shall be necessary to prevent loss upon a debt previously contracted in good faith, and in such cases, unless full payment of such debt is made, such stock shall be sold by the bank within twelve months from the date it was acquired.