add serialize as a jpeg func (occur some bugs)