Topographic imaging of materials by a scanning electron microscope (SEM), using the secondary electrons and backscattered electrons escaped from the surface under a primary electron beam bombardment as image signals, has been a very important technique in application to material sciences and the related fields. In this work we have developed a new parallel Monte Carlo simulation program to calculate SEM images especially for an inhomogeneous sample with a complex structure, which may be constructed with some basic geometrical shapes containing different materials. The ray-tracing arithmetic is employed to obtain the corrected electron flight step length for electrons across the interface of different zones containing distinct elements. We have done simulations for several specimens with artificial structures at the nm level. The results illustrate some new characters of image contrast, demonstrating the applicability of this image simulation technique to the characterization of nano-scale structure.