Approximate convexity principles and applications to PDEs in convex domains