I had the problem with my K5 and my Metz flash, TTL was random, it would be perfect for a few frames then over/under expose a couple of frames and then go back to perfect again. Same on my K-01, my Pentax Q has always worked perfectly.
After a little research I found I wasn't alone so I updated the firmware in the Metz flash and it now works perfectly on all my Pentax cameras every time, I still think the fault is in the cameras firmware though, Metz specifically mention that the update has been made necessary only for auto and manual operation on the K5 ll and K30, an older update was required for the K5 and a more recent one for the K-01 (all included in the latest download).
http://www.metz.de/index.php?eID=tx_nawsecuredl&u=0&file=fileadmin/fm-dam/Do...a98321af1c8700
It's as if Pentax have altered the flash function on every new model they release.
Chris