Context: State of the art quantitative spectroscopy of OB-stars compares synthetic spectra (calculated by means of 1D, spherically symmetric computer codes) with observations. Certain stellar atmospheres, however, show strong deviations from spherical symmetry, and need to be treated in 3D. Aims: We present 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 equation of radiative transfer, to study continuum- and line-scattering problems. Convergence has been accelerated by a non-local approximate Lambda-iteration scheme. Particular emphasis has been put on careful (spherically symmetric) test cases. Results: Typical errors of the source functions, when compared to 1D solutions, are of the order of 10-20 %, and increase for optically thick continua. 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 3D code, agree well with previous solutions using a 3D-SEI method. When compared with profiles resulting from the `analytic dynamical magnetosphere' (ADM) model, 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 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.