"Just to entertain" is a lot more fluent than "for the sake of entertaining" (You can see in Google Ngrams that "just to entertain" is much more common than "for the sake of entertaining") but neither one really sounds fluent or idiomatic.
Both of them say that he's doing something for the purpose of entertaining the fantasy; that is, "for the purpose of giving consideration to". That seems unnecessarily roundabout and wordy; he isn't checking ticket prices for the purpose of giving consideration to the fantasy, he's giving consideration to the fantasy by checking ticket prices.
I would just say "Entertaining the fantasy of traveling to another country, he..."