In any case in which a sheriff, acting pursuant to a contract entered into under this article, takes a prisoner into custody and transports him, such action shall be deemed lawful to the same extent as if he were the sheriff for whom he is performing such service.