fix incorrectly handling frames of size 65536