Square pipe

Hi, i make this square pipe (photo 1) from this rail (photo 2) but the endings of the profiles are not perfect. Any idea of how i can fix it?
image