You didn't specify the status of the device's connections: cellular and WiFi. However, you want to ensure that they are not connected in case you have your AppleID signed in on the device; you don't want messages to sync as they'll be deleted.
Before you turn it on, make sure it can't connect. Remove the SIM if necessary. As for WiFi, take it out of range of the network(s) you've used previously. If that's not possible, temporarily change your WiFi password (that's the simplest method). Once logged in, you can go to Airplane Mode and put everything back (i.e. WiFi password). The idea is not allow your phone the slightest opportunity to sync.
Once you are certain it's disconnected, so there's no chance of syncing with the cloud, open iMessage. There's no function to export messages, however you can take screenshots or forward them as mail messages.
- Screenshots can be saved and synced via USB using Finder on a Mac or iTunes in Windows.
- If you forward them as email messages, they will queue up in your outgoing mail folder until you connect to a network; they will all send at once.