Preparation of tensor network states