handle invalid encoded data correctly

Signed-off-by: Hagen Paul Pfeifer <hagen@jauu.net>