Context : State of the art quantitative spectroscopy utilizes synthetic spectra to extract information from observations . For hot , massive stars , these synthetic spectra are calculated by means of 1D , spherically symmetric , NLTE atmosphere and spectrum-synthesis codes . Certain stellar atmospheres , however , show strong deviations from spherical symmetry , and need to be treated in 3D . Aims : We present and test a newly developed 3D radiative transfer code , tailored to the solution of the radiation field in rapidly expanding stellar atmospheres . We apply our code to the continuum transfer in wind-ablation models , and to the UV resonance line formation in magnetic winds . Methods : We have used a 3D finite-volume method for the solution of the time-independent equation of radiative transfer , to study continuum- and line-scattering problems , currently approximated by a two-level-atom . Convergence has been accelerated by coupling the formal solver to a non-local approximate \Lambda -iteration scheme . Particular emphasis has been put on careful tests , by comparing with alternative solutions for 1D , spherically symmetric model atmospheres . These tests allowed us to understand certain shortcomings of the methods , and to estimate limiting cases that can actually be calculated . Results : The typical errors of the converged source functions , when compared to 1D solutions , are of the order of 10 - 20 \% , and rapidly increase for optically thick ( \tau \gtrsim 10 ) continua , mostly due to the order of accuracy of our solution scheme . In circumstellar discs , the radiation temperatures in the ( optically thin ) transition region from wind to disc are quite similar to corresponding values in the wind . For MHD simulations of dynamical magnetospheres , the line profiles , calculated with our new 3D code , agree well with previous solutions using a 3D-SEI method . When compared with profiles resulting from the so-called analytic dynamical magnetosphere ( ADM ) model , however , significant differences become apparent . Conclusions : Due to similar radiation temperatures in the wind and the transition region to the disc , the same line-strength distribution can be applied within radiation hydrodynamic calculations for optically thick circumstellar discs in ‘ accreting high-mass stars ’ . To properly describe the UV line formation in dynamical magnetospheres , the ADM model needs to be further developed , at least in a large part of the outer wind .