Added intermediate MemoryStream to try fix Azure issue