Hello Andreas,
It sounds like you have a sailmaking 101 problem. The luff curve made on your sail is more shallow than the luff curve your mast bends to in the upper part of your mast. When and where this happens,like at the first or second horrizontal batten down from the head for example, the sail goes flat here. The mast bend tries to pull the sail to a shape that is greater in width, luff to leech, than the sail is actually made to. Now the mainsheet load that was traveling up the leech of the sail migrates forward prematurely to the luff of the sail across this flat and tight sail area. This flat and tight area of the sail, one or two battens down from the top of the sail, takes the mainsheet load and delivers it to the mast one or two battens down from the top of the sail. Now the leech sail area above this point has very little tension in it and it falls off to leeward. If you take line of max leech tension from the clew to the second batten down from the top, for example, this line acts like a hinge. The sail area aft of this line falls off to leeward because the upper end of the leech at the square top is now falling off and it takes the leech with it. This will put an "S" shape into the sail. To correct this problem, your sail needs more luff round especially near the top. I would suggest you move the headboard aft about 2cm and refair the luff curve back into the original luff curve at the forward end of the gaff batten. This will put more luff round in the sail near the top of the luff curve and stop the sail from going flat prematurely at the second or third batten down from the top. Now the mainsheet/leech load will stay in the aft leech area of the sail until this load reaches the square top area of the sail where it will finally come forward and pull aft and down on the top of the mast. The leech will stand and the "S" shape in the sail will be gone. The hinge line has been eliminated.
Good luck,
Bill