Context : Regular follow-up of imaged companions to main-sequence stars often allows to detect a projected orbital motion . MCMC has become very popular in recent years for fitting and constraining their orbits . Some of these imaged companions appear to move on very eccentric , possibly unbound orbits . This is in particular the case for the exoplanet Fomalhaut b and the brown dwarf companion PZ Tel B on which we focus here . Aims : For such orbits , standard MCMC codes assuming only bound orbits may be inappropriate . Our goal is to develop a new MCMC implementation able to handle bound and unbound orbits as well in a continuous manner , and to apply it to the cases of Fomalhaut b and PZ Tel B . Methods : We present here this code , based on the use of universal Keplerian variables and Stumpff functions . We present two versions of this code , the second one using a different set of angular variables designed to avoid degeneracies arising when the projected orbital motion is quasi-radial , as it is the case for PZ Tel B . We also present additional observations of PZ Tel B Results : The code is applied to Fomalhaut b and PZ Tel B . Concerning Fomalhaut b , we confirm previous results , but we show that on the sole basis of the astrometric data , open orbital solutions are also possible . The eccentricity distribution nevertheless still peaks around \sim 0.9 in the bound regime . We present a first successful orbital fit of PZ Tel B , showing in particular that while both bound and unbound orbital solutions are equally possible , the eccentricity distribution presents a sharp peak very close to e = 1 , meaning a quasi-parabolic orbit . Conclusions : It was recently suggested that the presence of unseen inner companions to imaged ones may lead orbital fitting algorithms to artificially give very high eccentricities . We show that this caveat is unlikely to apply to Fomalhaut b . Concerning PZ Tel B , we derive a possible solution involving an inner ~ { } \sim 12 M _ { \mathrm { Jup } } companion that would mimic a e = 1 orbit despite a real eccentricity around 0.7 , but a dynamical analysis reveals that such a system would not be stable . We thus conclude that our orbital fit is robust .