"custody, for such time as appears to the court reasonably necessary for the purpose of delivering him into naval custody, and" . . . .