I have urls that point to pages I don't know yet if exist. Whenever reaching those, I perform a not-so-quick external sources check, and if exists generate the page on the fly. In order to avoid this behavior for search engine crawlers, I'm showing them a 404 header code. When a user comes, I'm first loading a status bar with flush() and then if I didn't find just display an error message with a 200 header code, because the headers are already sent in the flush() status bar. Whenever the page ends up as empty with an error message and a 200 code, it's like a 404 soft error.
Although my reasons are legit, I'm a bit concerned if Google might misinterpret this behavior and consider it cloaking?