It is the duty of the jailer to receive and safely keep, without any fee therefor, all inmates on their way to the penitentiary, whenever the sheriff or other officer in charge of such inmates may deem it necessary.