Sam and Gilly go to Oldtown in the book as well as in the show, but they go with an alive Maester Aemon. Well, kind of alive. He dies, on the way. Very sad, as arguably everyone loved Maester Aemon.
Sam and Gilly still travel to Oldtown in the book "A Feast for Crows," but they go with a very old and still alive Maester Aemon, and with Mance Rayder’s baby, not Gilly’s baby. Yes, Mance Rayder had a son, but the boy's mother died and he's been living at Castle Black. Jon Snow switches the babies and demands Maester Aemon be sent away with them. He makes the decision because Melisandre is rushing to burn anyone with “king's blood” to get Stannis on the throne, and he doesn’t want Mance Rayder's baby (who has king's blood since Mance Rayder was a king) or Aemon (whose father and brother were kings) being burned alive. Maester Aemon dies during travel from old age, but Sam and Gilly and Mance’s son make it to Oldtown.