Epitaxial thin films of the superconducting borocarbide compound YNi2B2C were grown on single crystal MgO (100) substrates without and with Y2O3 buffer layer using pulsed laser deposition (PLD). In both cases YNi2B2C grows with  normal to the substrate. However, the in-plane texture depends on the starting condition. For samples without buffer layer, oxygen from the substrate diffuses into the film and forms an Y2O3 reaction layer at the interface. As a consequence, a deficiency of Y is generated giving rise to the formation of secondary phases. On the other hand, using an artificial Y2O3 buffer layer secondary phases are suppressed. The texture of the Y2O3 layers determines the texture of the YNi2B2C film. The superconducting properties of the borocarbide films are discussed with respect to texture and phase purity.